package com.jixiantubu.adapter;

import java.util.ArrayList;
import java.util.List;
import com.example.jixiantubu.R;
import com.jixiantubu.bean.Wo_Data;

import image.SmartImageView;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class TupianAdapter extends BaseAdapter {
	LayoutInflater mInflater;
	Context context;
	ViewHolder mHolder;
	List<Wo_Data> list = new ArrayList<Wo_Data>();

	public TupianAdapter(Context context, List<Wo_Data> list) {
		super();
		this.context = context;
		this.list = list;
		mInflater = LayoutInflater.from(context);
	}

	public List<Wo_Data> getList() {
		return list;
	}

	public void setList(List<Wo_Data> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		if (arg1 == null) {
			arg1 = mInflater.inflate(R.layout.tupian_item, null);
			mHolder = new ViewHolder();
			mHolder.imageView = (ImageView) arg1
					.findViewById(R.id.tupianfenlei);
			mHolder.textView = (TextView) arg1
					.findViewById(R.id.tupianfenleimingzi);
			arg1.setTag(mHolder);
		} else {
			mHolder = (ViewHolder) arg1.getTag();
		}
		mHolder.imageView.setImageResource(list.get(arg0).getPicIcId());
		 mHolder.textView.setText(list.get(arg0).getText());
		return arg1;
	}

	class ViewHolder {
		ImageView imageView;
		TextView textView;
	}

}
